package com.ctibook.booksystem.dao.bookcatalog.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.cti.ftpservice.ftp.DateHelper;
import com.ctibook.booksystem.dao.bookcatalog.BookInfoUploadFileRecordDao;
import com.ctibook.booksystem.dao.books.common.impl.UploadFileRecordDaoImpl;
import com.ctibook.booksystem.model.bookcatalog.BookInfoUploadFileRecord;

@Repository("bookInfoUploadFileRecordDao")
public class BookInfoUploadFileRecordDaoImpl extends UploadFileRecordDaoImpl implements BookInfoUploadFileRecordDao {

	@Override
	public List<BookInfoUploadFileRecord> getRequireHandlerBookInfoUploadRecords() {
		String hql="from "+BookInfoUploadFileRecord.class.getName()+" t where t.parsed=:parsed";
		Map<String, Object> mapParams=new HashMap<String, Object>();
		mapParams.put("parsed", false);
		return getListObject(hql, mapParams);
	}

	@Override
	public List<BookInfoUploadFileRecord> getBookInfoUploadFileRecord(
			String startDate, String endDate, String parsered, String operaterId) {
		String hql="from "+BookInfoUploadFileRecord.class.getName()+" t where t.createTime between :startDate and :endDate";
		Map<String, Object> mapParams=new HashMap<String, Object>();
		mapParams.put("startDate", DateHelper.stringToDate(startDate+" 00:00:00", "yyyy-MM-dd hh:mm:ss"));
		mapParams.put("endDate", DateHelper.stringToDate(endDate+" 23:59:59", "yyyy-MM-dd hh:mm:ss"));
		if(!StringUtils.isBlank(parsered)){
			hql+=" and t.parsed=:parsed";
			mapParams.put("parsed",parsered.equals("是"));
		}
		if(!StringUtils.isBlank(operaterId)){
			hql+=" and t.creator.id=:createrId";
			mapParams.put("createrId",operaterId);
		}
		return getListObject(hql, mapParams);
	}

}
